﻿using Microsoft.AspNetCore.Mvc;
using OrleansDemo.Grain;
using System;
using System.Text;

namespace OrleansClient.Controllers
{
    [ApiController]
    [Route("[controller]/[action]")]
    public class TestController : ControllerBase
    {
        private IClusterClient _client;

        private static long _key = 0;

        public TestController(IClusterClient client)
        {
            _client = client;
        }

        [HttpGet]
        public async Task<string> SayHello()
        {
            Interlocked.Increment(ref _key);
            return await _client.GetGrain<IHello>(_key % 3).SayHello("你好");
        }

        [HttpGet]
        public async Task<string> SayHello2()
        {
            return await _client.GetGrain<IHello2>(0).SayHello("你好");
        }
    }
}
